home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 008a / perl40_2.zip / STAB.H < prev    next >
C/C++ Source or Header  |  1991-11-28  |  4KB  |  139 lines

  1. /* $RCSfile: stab.h,v $$Revision: 4.0.1.2 $$Date: 91/11/05 18:36:15 $
  2.  *
  3.  *    Copyright (c) 1991, Larry Wall
  4.  *
  5.  *    You may distribute under the terms of either the GNU General Public
  6.  *    License or the Artistic License, as specified in the README file.
  7.  *
  8.  * $Log:    stab.h,v $
  9.  * Revision 4.0.1.2  91/11/05  18:36:15  lwall
  10.  * patch11: length($x) was sometimes wrong for numeric $x
  11.  *
  12.  * Revision 4.0.1.1  91/06/07  11:56:35  lwall
  13.  * patch4: new copyright notice
  14.  * patch4: length($`), length($&), length($') now optimized to avoid string copy
  15.  *
  16.  * Revision 4.0  91/03/20  01:39:49  lwall
  17.  * 4.0 baseline.
  18.  *
  19.  */
  20.  
  21.  
  22. struct stabptrs {
  23.     char        stbp_magic[4];
  24.     STR        *stbp_val;    /* scalar value */
  25.     struct stio *stbp_io;    /* filehandle value */
  26.     FCMD    *stbp_form;    /* format value */
  27.     ARRAY    *stbp_array;    /* array value */
  28.     HASH    *stbp_hash;    /* associative array value */
  29.     HASH    *stbp_stash;    /* symbol table for this stab */
  30.     SUBR    *stbp_sub;    /* subroutine value */
  31.     int        stbp_lastexpr;    /* used by nothing_in_common() */
  32.     line_t    stbp_line;    /* line first declared at (for -w) */
  33.     char    stbp_flags;
  34. };
  35.  
  36.  
  37. #if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286))
  38. #define MICROPORT
  39. #endif
  40.  
  41.  
  42. #define stab_magic(stab)    (((STBP*)(stab->str_ptr))->stbp_magic)
  43. #define stab_val(stab)        (((STBP*)(stab->str_ptr))->stbp_val)
  44. #define stab_io(stab)        (((STBP*)(stab->str_ptr))->stbp_io)
  45. #define stab_form(stab)        (((STBP*)(stab->str_ptr))->stbp_form)
  46. #define stab_xarray(stab)    (((STBP*)(stab->str_ptr))->stbp_array)
  47. #ifdef    MICROPORT    /* Microport 2.4 hack */
  48. ARRAY *stab_array();
  49. #else
  50. #define stab_array(stab)    (((STBP*)(stab->str_ptr))->stbp_array ? \
  51.                  ((STBP*)(stab->str_ptr))->stbp_array : \
  52.                  ((STBP*)(aadd(stab)->str_ptr))->stbp_array)
  53. #endif
  54. #define stab_xhash(stab)    (((STBP*)(stab->str_ptr))->stbp_hash)
  55. #ifdef    MICROPORT    /* Microport 2.4 hack */
  56. HASH *stab_hash();
  57. #else
  58. #define stab_hash(stab)        (((STBP*)(stab->str_ptr))->stbp_hash ? \
  59.                  ((STBP*)(stab->str_ptr))->stbp_hash : \
  60.                  ((STBP*)(hadd(stab)->str_ptr))->stbp_hash)
  61. #endif            /* Microport 2.4 hack */
  62. #define stab_stash(stab)    (((STBP*)(stab->str_ptr))->stbp_stash)
  63. #define stab_sub(stab)        (((STBP*)(stab->str_ptr))->stbp_sub)
  64. #define stab_lastexpr(stab)    (((STBP*)(stab->str_ptr))->stbp_lastexpr)
  65. #define stab_line(stab)        (((STBP*)(stab->str_ptr))->stbp_line)
  66. #define stab_flags(stab)    (((STBP*)(stab->str_ptr))->stbp_flags)
  67. #define stab_name(stab)        (stab->str_magic->str_ptr)
  68.  
  69.  
  70. #define SF_VMAGIC 1        /* call routine to dereference STR val */
  71. #define SF_MULTI 2        /* seen more than once */
  72.  
  73.  
  74. struct stio {
  75.     FILE    *ifp;        /* ifp and ofp are normally the same */
  76.     FILE    *ofp;        /* but sockets need separate streams */
  77. #ifdef HAS_READDIR
  78.     DIR        *dirp;        /* for opendir, readdir, etc */
  79. #endif
  80.     long    lines;        /* $. */
  81.     long    page;        /* $% */
  82.     long    page_len;    /* $= */
  83.     long    lines_left;    /* $- */
  84.     char    *top_name;    /* $^ */
  85.     STAB    *top_stab;    /* $^ */
  86.     char    *fmt_name;    /* $~ */
  87.     STAB    *fmt_stab;    /* $~ */
  88.     short    subprocess;    /* -| or |- */
  89.     char    type;
  90.     char    flags;
  91. };
  92.  
  93.  
  94. #define IOF_ARGV 1    /* this fp iterates over ARGV */
  95. #define IOF_START 2    /* check for null ARGV and substitute '-' */
  96. #define IOF_FLUSH 4    /* this fp wants a flush after write op */
  97.  
  98.  
  99. struct sub {
  100.     CMD        *cmd;
  101.     int        (*usersub)();
  102.     int        userindex;
  103.     STAB    *filestab;
  104.     long    depth;    /* >= 2 indicates recursive call */
  105.     ARRAY    *tosave;
  106. };
  107.  
  108.  
  109. #define Nullstab Null(STAB*)
  110.  
  111.  
  112. STRLEN stab_len();
  113.  
  114.  
  115. #define STAB_STR(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_str(stab_val(tmpstab)->str_magic) : stab_val(tmpstab))
  116. #define STAB_LEN(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_len(stab_val(tmpstab)->str_magic) : str_len(stab_val(tmpstab)))
  117. #define STAB_GET(s) (tmpstab = (s), str_get(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab)))
  118. #define STAB_GNUM(s) (tmpstab = (s), str_gnum(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab)))
  119.  
  120.  
  121. EXT STAB *tmpstab;
  122.  
  123.  
  124. EXT STAB *stab_index[128];
  125.  
  126.  
  127. EXT unsigned short statusvalue;
  128.  
  129.  
  130. EXT int delaymagic INIT(0);
  131. #define DM_DELAY 1
  132. #define DM_REUID 2
  133. #define DM_REGID 4
  134.  
  135.  
  136. STAB *aadd();
  137. STAB *hadd();
  138. STAB *fstab();
  139.